var systemInterfaceParam=null;
$(document).ready(function(){
	
		$('#ComboxSearchOperation').combobox({
			url:BASE_URL_DATA_DICTIONARY_VALUE_SEARCH +'/findByTypeCode?typeCode='+DDTC_USER_OPERATION + '&v=' + Math.random(),
			valueField: 'valueCode',
		    textField: 'valueName',
		    editable: false,
		    method:'get',
		    loadFilter: function(data){
		    	var allCheck = {'valueCode':'','valueName':'全部'};
		    	data.unshift(allCheck);
		    	return data;
		    }
		})
		$("#datagrid").datagrid({
			url : BASE_URL_USER_LOG_SEARCH + '/findByExample' + '?v=' + Math.random(),
			method:'get',
			autoRowHeight:true,
			nowrap:false,
			singleSelect:true,
			striped:true,
			pageSize:20,
			pageList:[10,20,50,100],
			columns:[[
						{field:'optPerson',title:'操作人',width:70,align:'left'},
						{field:'userCode',title:'操作账号',width:70,align:'left'},
						{field:'optTime',title:'操作时间',width:90},
						{field:'loginIp',title:'IP地址',width:70},
						{field:'optTypeForDisplay',title:'操作',width:60},
						{field:'contents',title:'详细信息',width:300,align:'left'}
			      ]],
			pagination:true,
			onSelect:function(rowIndex,rowData){
				$("#toolbar_edit").linkbutton('enable');
				$("#toolbar_delete").linkbutton('enable');
			},
			loadFilter:function(data){
				//alert("inData:"+JSON.stringify(data));
				return {
					total: data.totalElements,
					rows: data.content
				};
			},
			onBeforeLoad:function(param){
				param.page -= 1;
				param.size = param.rows;
				delete param.rows;
				
				
				param.sort = 'createTime,desc';
				var optPerson = $('#txtSearchOperator').val();
				if(optPerson != '全部'){
					//alert("getText:"+fieldName);
					if(optPerson !=""){
						param.optPerson = optPerson;
					}
				}
				
				
				 
				var beginOfCreateTime = $('#txtBeginTime').datetimebox('getValue');
				if(beginOfCreateTime !=""){
					param.beginOfCreateTime = beginOfCreateTime;
				}
				
				var endOfCreateTime = $('#txtEndTime').datetimebox('getValue');
				if(endOfCreateTime !=""){
					param.endOfCreateTime = endOfCreateTime;
				}
				
				var optType = $('#ComboxSearchOperation').combobox('getValue');
				if(optType != '全部'){
					//alert("getText:"+fieldName);
					if(optType !=""){
						param.optType = optType;
					}
				}
				systemInterfaceParam = param;
			}
		});
		
		$("#datagrid").datagrid('getPager').pagination({   
		    displayMsg:'当前显示从 [{from}] 到 [{to}] 共[{total}]条记录'
		}); 

});
	//查询
	function search(){
		dataRetrieval('#txtBeginTime', '#txtEndTime');
	}
	
	function exportData(){
		$('#datagrid').datagrid({
			url:BASE_URL_USER_LOG_SEARCH + '/findByExample' + '?v=' + Math.random()
		});
		var param = JSON.stringify(systemInterfaceParam);
		location.href= BASE_URL_EXPORTDATA_FILE + '/userLogExport?param='+param;
	}